home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan / Opus 5 - Magellan.iso / DOpus_Install / ARexx / ARexx / VersionCopy.dopus5 < prev    next >
Text File  |  1996-05-03  |  3KB  |  113 lines

  1. /*
  2.   $VER: VersionCopy.dopus5 1.3 (11.3.96)
  3.   Written by Edmund Vermeulen (edmundv@grafix.xs4all.nl).
  4.  
  5.   ARexx script for Directory Opus 5.5 that shows the version information
  6.   of all existing files before copying them.
  7.  
  8.   Function : ARexx      DOpus5:ARexx/VersionCopy.dopus5 {Qp}
  9. */
  10.  
  11. parse arg portname
  12. if portname='' then
  13.    portname='DOPUS.1'
  14. address value portname
  15.  
  16. options results
  17. options failat 21
  18. lf='0a'x  /* linefeed */
  19.  
  20. src=0
  21. dst=1
  22.  
  23. lister query source
  24. if rc>0 then do
  25.    dopus request '"No source selected." OK'
  26.    exit
  27.    end
  28. parse var result handle.src .
  29. lister query handle.src path
  30. path.src=result
  31.  
  32. lister query dest
  33. if rc>0 then do
  34.    dopus request '"No destination selected." OK'
  35.    exit
  36.    end
  37. parse var result handle.dst .
  38. lister query handle.dst path
  39. path.dst=result
  40.  
  41. lister set handle.src busy on
  42. lister set handle.dst busy on
  43.  
  44. lister query handle.src numseldirs
  45. if result>0 then do
  46.    dopus request '"VersionCopy cannot check version'lf||,
  47.                  'information of files in directories.'lf||lf||,
  48.                  'Do you want to copy them anyway?" Copy|Skip|Abort'
  49.    if rc=0 then do
  50.       lister set handle.src busy off
  51.       lister set handle.dst busy off
  52.       exit
  53.       end
  54.    if rc=2 then do
  55.       lister query handle.src seldirs stem dir.
  56.       do i=0 to dir.count-1
  57.          lister select handle.src '"'dir.i'"' off
  58.          end         
  59.       end
  60.    end
  61.  
  62. lister query handle.src selfiles stem file.
  63. lister set handle.src newprogress name bar abort
  64. lister set handle.src newprogress title 'Comparing...'
  65.  
  66. do i=0 to file.count-1
  67.    lister set handle.src newprogress name file.i
  68.    lister set handle.src newprogress bar file.count i+1
  69.  
  70.    if exists(path.dst||file.i) then do  /* does it already exist? */
  71.       do j=0 to 1
  72.          address command 'Version >T:Version.temp "'path.j||file.i'" FILE FULL'
  73.          if rc=0 then do
  74.             call open('tempfile','T:Version.temp','r')
  75.             version.j=readln('tempfile')
  76.             call close ('tempfile')
  77.             if length(version.j)>48 then
  78.                version.j=left(version.j,45)'...'
  79.             end
  80.          else
  81.             version.j='no version info found'
  82.          lister query handle.j entry '"'file.i'"' stem fileinfo.
  83.          size.j=fileinfo.size
  84.          end
  85.       command delete quiet 'T:Version.temp'
  86.  
  87.       dopus request '"File '''file.i''' already exists. Replace it?'lf||lf||,
  88.                     'New :' version.src '- Size :' size.src||lf||,
  89.                     'Old :' version.dst '- Size :' size.dst'" Replace|Skip|Abort'
  90.       choice=rc
  91.       if choice=2 then
  92.          lister select handle.src '"'file.i'"' off
  93.  
  94.       lister query handle.src abort
  95.       if result|choice=0 then do
  96.          lister refresh handle.src
  97.          lister clear handle.src progress
  98.          lister set handle.src busy off
  99.          lister set handle.dst busy off
  100.          exit
  101.          end
  102.       end
  103.    end
  104.  
  105. lister clear handle.src progress
  106. lister refresh handle.src
  107. lister set handle.src busy off
  108. lister set handle.dst busy off
  109.  
  110. lister set handle.src source
  111. lister set handle.dst dest
  112. command copy quiet
  113.